<?php

class User{
	private $_id;
	private $_name = "Dupont";
	private $_firstName = "Toto";
	private $_email = "";
	private $_login ="";
	private $_password ="";
	
	const USER_TYPE = "Toto";
	
	//Constructeur / Destructeur
	public function __construct(){}
  
	public function __destruct(){}
	
	
	//GETTER & SETTER
	public function getName(){
		return $this->_name;	
	}
	
	public function setName($value){
		$this->_name = $value;	
	}
	
	public function getId(){
		return $this->_id;	
	}
	
	public function setId($value){
		$this->_id = $value;	
	}
	
	public function setEmail($value){
		$this->_email = $value;	
	}
	
	public function getEmail(){
		return $this->_email;	
	}
	
	public function getFirstName(){
		return $this->_firstName;	
	}
	
	public function setFirstName($value){
		$this->_firstName = $value;	
	}
	
	public function getLogin(){
		return $this->_login;	
	}
	
	public function setLogin($value){
		$this->_login = $value;	
	}
	
	public function getPassword(){
		return $this->_password;	
	}
	
	public function setPassword($value){
		$this->_password = $value;	
	}
	
	// Save
	public function save($connexion){
		//préparation de la requete
		$query= "INSERT INTO User (id, login, password, name, firstname, email ) 
		VALUES ('',	'".$this->_login."','".$this->_password."','".$this->_name."','".$this->_firstName."','".$this->_email."');";
		//execution de la requete
		$resultat = $connexion->exec($query);
		return $resultat;		
	}
	
	//getList
	public static function getList($connexion){
		//préparation de la requete
		$query= "SELECT * FROM User ;";
		//execution de la requete
		$resultat = $connexion->query($query);
		return $resultat;		
	}
	
}

?>